using System;
using System.Collections.Generic;
using System.Text;

namespace BTV.Base.Search.Equality
{
    public abstract class BaseEqualityOperator
    {

        public abstract string Value
        {
            get;
        }

        public abstract bool PerformEquality(object input, object equality);

        public override string ToString()
        {
            return Value;
        }

        public static BaseEqualityOperator GetOperator(string value)
        {
            Dictionary<string, BaseEqualityOperator> types = new Dictionary<string,BaseEqualityOperator>();
            ContainsEqualityOperator ceo = new ContainsEqualityOperator();
            types.Add(ceo.Value, ceo);
            EqualsEqualityOperator eeo = new EqualsEqualityOperator();
            types.Add(eeo.Value, eeo);
            GreaterThanEqualityOperator gteo = new GreaterThanEqualityOperator();
            types.Add(gteo.Value, gteo);
            GreaterThanOrEqualsEqualityOperator gtoeo = new GreaterThanOrEqualsEqualityOperator();
            types.Add(gtoeo.Value, gtoeo);
            LessThanEqualityOperator lteo = new LessThanEqualityOperator();
            types.Add(lteo.Value, lteo);
            LessThanOrEqualsEqualityOperator ltoeo = new LessThanOrEqualsEqualityOperator();
            types.Add(ltoeo.Value, ltoeo);
            LikeEqualityOperator lieo = new LikeEqualityOperator();
            types.Add(lieo.Value, lieo);
            NotContainsEqualityOperater nceo = new NotContainsEqualityOperater();
            types.Add(nceo.Value, nceo);
            NotEqualsEqualityOperator neeo = new NotEqualsEqualityOperator();
            types.Add(neeo.Value, neeo);

            BaseEqualityOperator op;
            if (types.TryGetValue(value, out op))
                return op;
            else
                return null;
        }
    }
}
